

#ifndef GRTMATRIX_H
#define GRTMATRIX_H

#include <math.h>


// ------------------------- GRTMatrix{} -------------------------------------
// ---------------------------------------------------------------------------
class GRTMatrix
{
public:
	GRTMatrix();
	GRTMatrix( const GRTMatrix & matrix );
	
	enum Unit
	{
		RADIANS,
		DEGREES
	};
	
	Unit unit() const { return _unit; }
	void setUnit( const Unit unit ) { _unit = unit; }
		
	
	void reset();
	void setMatrix( const GRTMatrix & matrix );
	
	double m( int indexX, int indexY ) const;
	void setM( int indexX, int indexY, double value );
	
	double m11() const { return _matrix[0][0]; }
	double m12() const { return _matrix[0][1]; }
	double m13() const { return _matrix[0][2]; }
	double m14() const { return _matrix[0][3]; }
	
	double m21() const { return _matrix[1][0]; }
	double m22() const { return _matrix[1][1]; }
	double m23() const { return _matrix[1][2]; }
	double m24() const { return _matrix[1][3]; }
	
	double m31() const { return _matrix[2][0]; }
	double m32() const { return _matrix[2][1]; }
	double m33() const { return _matrix[2][2]; }
	double m34() const { return _matrix[2][3]; }
	
	double m41() const { return _matrix[3][0]; }
	double m42() const { return _matrix[3][1]; }
	double m43() const { return _matrix[3][2]; }
	double m44() const { return _matrix[3][3]; }
	
	double translationX() const { return m14(); }
	double translationY() const { return m24(); }
	double translationZ() const { return m34(); }
	
	void translateX( const double dx );
	void translateY( const double dy );
	void translateZ( const double dz );
	
	void rotateX( const double alpha );
	void rotateY( const double beta );
	void rotateZ( const double gamma );
	
	GRTMatrix operator * ( const GRTMatrix matrix ) const;
	GRTMatrix operator + ( const GRTMatrix matrix ) const;
	GRTMatrix operator - ( const GRTMatrix matrix ) const;
	GRTMatrix operator = ( const GRTMatrix matrix );
	
	QString toString();
	
private:
	double _matrix[4][4];
	Unit   _unit;
	
	double angle( const double ang );

}; // class !GRTMatrix
// ---------------------------------------------------------------------------

#endif // !GRTMATRIX_H

// eof
